package com.allprs.hmcs.service.impl;

import com.allprs.common.core.domain.AjaxResult;
import com.allprs.common.utils.StringUtils;
import com.allprs.hmcs.entity.Catchment;
import com.allprs.hmcs.mapper.CatchmentMapper;
import com.allprs.hmcs.pojo.reqBo.CatchmentQueryBo;
import com.allprs.hmcs.service.ICatchmentService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wjf
 * @描述: 汇水区
 * @date 2024年06月14日
 * @version: 1.0
 */

@Service
public class CatchmentServiceImpl implements ICatchmentService {

    @Resource
    private CatchmentMapper catchmentMapper;

    @Override
    public AjaxResult getCatchmentInfo(CatchmentQueryBo queryBo) {
        QueryWrapper<Catchment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(StringUtils.isNotBlank(queryBo.getName()), "name", queryBo.getName())
                .eq(queryBo.getId() != 0, "id", queryBo.getId());
        List<Catchment> catchmentList = catchmentMapper.selectList(queryWrapper);
        return AjaxResult.success(catchmentList);
    }
}
